updating oE display

display

include console.e 
default namespace is console 
public procedure display(object data_in, object args = 1, integer finalnl = - 918_273_645) 

Displays the supplied data on the console screen at the current cursor position. display() is most useful when used with formatting tokens from std/text.e.

Parameters:
  1. data_in : Any object.
  2. args : Optional arguments used to format the output.
  3. finalnl : Optional. Determines if a new line is output after the data. Default is to output a new line.
Comments:
  • If data_in is an atom or integer, it is simply displayed.
  • If data_in is a simple text string, then args can be used to produce a formatted output with data_in providing the text:format string and args being a sequence containing the data to be formatted.
    • If the last character of data_in is an underscore character then it is stripped off and finalnl is set to zero. Thus ensuring that a new line is not output.
    • The formatting codes expected in data_in are the ones used by text:format. It is not mandatory to use formatting codes, and if data_in does not contain any then it is simply displayed and anything in args is ignored.
  • If data_in is a sequence containing floating-point numbers, sub-sequences or integers that are not characters, then data_in is forwarded on to the pretty_print to display.
    • If args is a non-empty sequence, it is assumed to contain the pretty_print formatting options.
    • if args is an atom or an empty sequence, the assumed pretty_print formatting options are assumed to be {2}.

After the data is displayed, the routine will normally output a New Line. If you want to avoid this, ensure that the last parameter is a zero. Or to put this another way, if the last parameter is zero then a New Line will not be output.

Example 1:
include std/console.e 
 
display("Some plain text")  
        -- Displays this string on the console plus a new line. 
 
display("What is sharp on one end and all four corners? ",0)   
       -- Displays this string on the console without a new line. 
 
display("A cat") 
 
display("Eggs and [] ",{"Bacon"},0) -- 0 as 3rd parameter means  "no line feed" 
display("Toast and []_",{"Jam"})  -- underscore as last character in format string means same thing. 
display(" for breakfast") 
 
display({"abc", 3.44554})  
       -- Displays the sequence on the console, complete with braces. 
 
display("The answer to '[2]' was [1]", {21*2,"why"})  
       -- formats these with a new line, note ability to select by position. 
 
sequence now = date() 
? now 
display("The time is [4]:[5]:[6]",now) 
 
display("[u] $[:08]",{"price",12.34}) -- see std/text.e for formatting tokens 
 
display({51,362,71}, {1}) 
Results:

Some plain text 
What is sharp on one end and all four corners? A cat 
Eggs and Bacon Toast and Jam for breakfast 
{ 
  "abc", 
  3.44554 
} 
The answer to 'why' was 42 
{119,9,14,9,42,13,7,257} 
The time is 9:43:13 
PRICE $00012.34 
{51'3',362,71'G'} 

Not Categorized, Please Help

Search



Quick Links

User menu

Not signed in.

Misc Menu